package com.example.demo.service;

import com.example.demo.bean.shop;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service //将类交由spring管理
public class shopService  {

    @Autowired
    private com.example.demo.Dao.shopdao shopdao;

    /**
     * 添加信息
     * @paramshopid,shopname,shopprice,shopamount
     * @returnint shopid,String shopname,String shopprice, String shopamount
     */
    public int Insertshop(shop shop){shopdao.insert(shop);
        return 1;
    }

    /**
     * 通过商品编号删除数据
     * @param
     * @return
     */
    public int Deleteshop(Integer shopid){
        shopdao.deleteById(shopid);
        return 1;
    }

    /**
     * 修改信息
     * @paramint shopid,String shopname,String shopprice, String shopamount
     * @returnshopid,shopname,shopprice,shopamount
     */
    public int Updateshop(shop shop) {
        shopdao.updateById(shop);
        return 1;
    }

    /**
     * 显示所有数据
     * @return
     */
    public List<shop> ShowAllshop() {
        return shopdao.ShowAllshop();
    }

    /**
     * 通过名称查询数据
     * @param number
     * @return
     */
//    public shop Showshop(Integer number){
//        return shopdao.Showshop(number);
//    }

    /**
     * 查询商品总数
     * @return
     */
    public int Totalshop(){
        shopdao.Totalshop();
        return 1;
    };
}
